import { Entity, PrimaryGeneratedColumn, Column, OneToOne, OneToMany, JoinColumn } from 'typeorm'
import { Material } from './material.entity'
import { MaterialContentNewsItem } from './material-content-item.entity'
@Entity()
export class MaterialContent {
  @PrimaryGeneratedColumn()
  id: number

  @Column({
    default: 0
  })
  create_time: number

  @Column({
    default: 0
  })
  update_time: number

  @OneToMany(type => MaterialContentNewsItem, item => item.materialContent, {
    cascade: ['insert'],
    eager: true
  })
  news_item: MaterialContentNewsItem[]

  // 从表
  @OneToOne(type => Material, material => material.content, {
    cascade: ['remove', 'insert', 'update']
  })
  @JoinColumn()
  material: Material
}
